#!/usr/bin/env bash

STATIC_IP=192.168.56.202
hostnamectl set-hostname k8s-node2.cn
IFCFG=/etc/sysconfig/network-scripts/ifcfg-enp0s3
echo "setup for $IFCFG"
mv $IFCFG $IFCFG.bak
cat <<EOF >> $IFCFG
TYPE=Ethernet
BOOTPROTO=dhcp
DNS1=192.168.1.1
DNS2=192.168.0.1
NAME=enp0s3
DEVICE=enp0s3
ONBOOT=yes
EOF

IFCFG=/etc/sysconfig/network-scripts/ifcfg-enp0s8
echo "setup for $IFCFG"
mv $IFCFG $IFCFG.bak
cat <<EOF >> $IFCFG
TYPE=Ethernet
BOOTPROTO=static
IPADDR=$STATIC_IP
NETMASK=255.255.255.0
GATEWAY=192.168.56.1
DNS1=192.168.56.1
NAME=enp0s8
DEVICE=enp0s8
ONBOOT=yes
EOF

echo "setup dns"
cat <<EOF >> /etc/hosts
192.168.56.200 k8s200.cn k8s-master.cn
192.168.56.201 k8s201.cn k8s-node1.cn
192.168.56.202 k8s202.cn k8s-node2.cn
EOF

cat /etc/hosts